/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;

import controller.DeviceDetail;
import controller.EditDevice;
import controller.EditReport;
import controller.ListReports;
import entities.Device;
import entities.Report;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author QUY-THI
 */
@ManagedBean
@SessionScoped
public class ListReportNoBean {

    private List<Report> reports;
    private List<Report> yesreport;

    public List<Report> getYesreport() {
        ListReports lr = new ListReports();
        List<Report> re = lr.getReports();
        List<Report> list = new ArrayList<Report>();
        for (Report repor : re) {
            if (repor.getStatus()) {
                list.add(repor);
            }
        }
        return list;
    }

    public void setYesreport(List<Report> yesreport) {
        this.yesreport = yesreport;
    }
    private Report report;

    public List<Report> getReports() {
        return getNewReport();
    }

    public void setReports(List<Report> reports) {
        this.reports = reports;
    }

    public Report getReport() {
        return report;
    }

    public void setReport(Report report) {
        this.report = report;
    }

    public List<Report> getNewReport() {
        ListReports lr = new ListReports();
        List<Report> re = lr.getReports();
        List<Report> list = new ArrayList<Report>();
        for (Report repor : re) {
            if (!repor.getStatus()) {
                list.add(repor);
            }
        }
        return list;
    }

    /**
     * Creates a new instance of ListReportNoBean
     */
    public ListReportNoBean() {
    }

    public String resultEdit() {
        report.setStatus(Boolean.TRUE);
        DeviceDetail dd = new DeviceDetail();
        Device d = dd.deviceDetail(report.getDeviceID().getDeviceID());
        d.setIsProlem(Boolean.FALSE);
        EditDevice ed = new EditDevice();
        EditReport er = new EditReport();
        ed.editDevice(d);
        er.editReport(report);
        return "reportInfo.xhtml?faces-redirect=true";
    }
}
